package homework.Thirty;

import mongodb.Address;

import java.awt.*;
import java.awt.event.KeyEvent;

public class KeyMouse {
    public static void main(String[] args) {
        Frame frame=new Frame();
        MyButton b=new MyButton("Button");
        frame.setLayout(new BorderLayout());
        frame.add("North",b);
        frame.validate();
        frame.setVisible(true);
        b.requestFocus();
    }
}

class MyButton extends Button{
    MyButton(String b){
        super(b);
        enableEvents(AWTEvent.KEY_EVENT_MASK);
        enableEvents(AWTEvent.MOUSE_EVENT_MASK);
        enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK);
    }

    @Override
    public void processKeyEvent(KeyEvent e){
        if (e.getID()==KeyEvent.KEY_PRESSED){
            int code=e.getKeyCode();
            int m=e.getModifiers();
            System.out.println("\n---------------Key?");
            System.out.println("getKeyChar():\t"+e.getKeyChar());
            System.out.println("getKeyCode):\t"+code);
            System.out.println("getKeyText():\t"+e.getKeyText(code));

        }
    }



}
